<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title><?php echo config('shopName');?> - 添加新文章 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="<?=ADMIN_CSS;?>/general.css" rel="stylesheet" type="text/css" />
    <link href="<?=ADMIN_CSS;?>/main.css" rel="stylesheet" type="text/css" />
    <script src="<?=JQ_UI;?>/datetimepicker/jquery.js"></script>
    <link rel="stylesheet" type="text/css" href="<?=JQ_UI;?>/datetimepicker/jquery.datetimepicker.css"/ >
    <script src="<?=JQ_UI;?>/datetimepicker/jquery.datetimepicker.js"></script>
    <script src="<?=UEDITOR;?>/ueditor.config.js"></script>
    <script src="<?=UEDITOR;?>/ueditor.all.min.js"></script>
</head>
<body>
<h1>
    <span class="action-span"><a href="<?php echo url("Admin/Article/lst")?>">文章列表</a>
    </span>
    <span class="action-span1"><a href="<?php echo url("Admin/Index/main")?>"><?php echo config('shopName');?></a></span>
    <span id="search_id" class="action-span1"> - 添加新文章 </span>
    <div style="clear:both"></div>
</h1>

<div class="tab-div">
    <div id="tabbar-div">
        <p>
            <span class="tab-front">通用信息</span>
            <span class="tab-back">文章内容</span>
        </p>
    </div>
    <form enctype="multipart/form-data" action="<?php echo url("Admin/Article/add")?>" method="post">
        <div class="tabbody-div">
            <table cellspacing="1" cellpadding="3" width="100%">
                <input type="hidden" id="logo" size="40" name="article_img" />
                <tr>
                    <td class="label">文章标题</td>
                    <td>
                        <input type="text" name="title" maxlength="60" size="40" value="" />
                        <span class="require-field">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">副标题</td>
                    <td>
                        <input type="text" name="short_title" maxlength="200" size="60" value="" />
                    </td>
                </tr>
                <tr>
                    <td class="label">封面缩略图</td>
                    <td>
                        <img id="pre_img" src="<?=JQ_UI;?>/webuploader/image.png" style="cursor: pointer;border: 1px solid #ccc;" title="可更换"/><span style="color: red" id="test_pre_img"></span>
                    </td>
                </tr>
                <tr>
                    <td class="label">发布时间</td>
                    <td>
                        <input type="text" class="datetime" id="add_time" name="add_time" maxlength="60" size="40" value="" />
                    </td>
                </tr>
                <tr>
                    <td class="label">文章分类</td>
                    <td>
                        <select name="cat_id">
                            <option  value="">请选择...</option>
                            <?php foreach ($article_cat_data as $k=>$v): ?>
                                <option  value="<?php echo $v['cat_id'];?>" style="padding-left: <?php echo 25*$v['level']?>px"><?php echo $v['cat_name'];?></option>
                            <?php endforeach; ?>
                        </select>
                        <span class="require-field">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">文章重要性</td>
                    <td>
                        <input type="radio" name="article_type" value="0" checked="checked" /> 普通
                        <input type="radio" name="article_type" value="1"  /> 置顶
                    </td>
                </tr>
                <tr>
                    <td class="label">是否显示</td>
                    <td>
                        <input type="radio" name="is_open" value="1" checked="checked" /> 显示
                        <input type="radio" name="is_open" value="0"  /> 不显示
                    </td>
                </tr>
                <tr>
                    <td class="label">点击次数</td>
                    <td>
                        <input type="text" name="count" maxlength="6" size="6" value="" />
                    </td>
                </tr>
                <tr>
                    <td class="label">关键字</td>
                    <td>
                        <input type="text" name="keywords" maxlength="200" size="60" value="" />
                    </td>
                </tr>
                <tr>
                    <td class="label">网页描述</td>
                    <td>
                        <textarea  name="description" cols="60" rows="4"  ></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <div class="tabbody-div" style="display: none">
            <textarea name="content" id="content"></textarea>
            <script>
                // 把textarea替换成一个编辑器
                UE.getEditor('content',{
                    initialFrameWidth:"100%",
                    initialFrameHeight:"300"
                });
            </script>
        </div>
        <div class="button-div">
            <input type="submit" value=" 确定 " class="button"/>
            <input type="reset" value=" 重置 " class="button" />
        </div>
    </form>
</div>

<script>
    $(function () {
        $("#tabbar-div p span").click(function(){
            // 先去掉原选中状态
            $(".tab-front").removeClass("tab-front").addClass("tab-back");
            // 把当前按钮变成选中状态
            $(this).removeClass("tab-back").addClass("tab-front");
            // 当前是第几个按钮
            var i = $(this).index();
            // 先隐藏所有的div
            $(".tabbody-div").hide();
            // 显示相应的div
            $(".tabbody-div").eq(i).show();
        });
    })
</script>

<?php require_once  resource_path('view/public/footer.php');?>
</body>
</html>


<!--图片上传 start-->
<iframe style="display:none;" name="ifr"></iframe>
<div id="upload" style="display: none">
    <form id="pre_form" target="ifr" method="POST" action="<?php echo url('Admin/Ad/ajaxUpload');?>" enctype="multipart/form-data">
        <input type="file" name="img" onchange="ajaxUpload();"/>
    </form>
</div>
<!--图片上传 end-->

<script>
    $(function(){
        $('.datetime').datetimepicker({
            lang:'ch', //选择中文
            format:'Y-m-d H:i:s', //格式化日期时间
//            timepicker:false, //去掉时间
//            maxDate:'+1970/01/01',  //最大日期是今天
            yearStart:2015,  //最小年份
        });
        //当点击图片的时候，让它去点击上传按钮，再触发提交表单
        $('#pre_img').click(function () {
            $("#pre_form input[name='img']").click();
        });

        //广告位大小
        $('#adpos_id').change(function () {
            if($(this).val() >0)
            {
                var width = $(this).find("option:selected").data('width');
                var height = $(this).find("option:selected").data('height');
                $('#ad_size').val(width+','+height);
            }
            else
            {
                $('#ad_size').val('');
            }
        });


    });

    function ajaxUpload()
    {
        $('#pre_form').submit();
    }
</script>